package com.mars.diancan.dto;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.mars.diancan.common.OrderStatusEnum;
import com.mars.diancan.common.PayStatusEnum;
import com.mars.diancan.pojo.OrderDetail;
import com.mars.diancan.utils.Date2LongSerializer;
import com.mars.diancan.utils.EnumUtil;
import lombok.Data;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * 订单数据传输转换实体类
 * @author MARS
 * @date 2018/6/25
 */
@Data
//@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
//@JsonInclude(JsonInclude.Include.NON_NULL)
public class OrderDTO {
    private String orderId;
    private String buyerName;
    private String buyerPhone;
    private String buyerAddress;
    private String buyerOpenid;
    private BigDecimal orderAmount;
    private Integer orderStatus ;
    private Integer payStatus ;

    @JsonSerialize(using = Date2LongSerializer.class)
    private Date createTime;

    @JsonSerialize(using = Date2LongSerializer.class)
    private Date updateTime;
    
    List<OrderDetail> orderDetailList;


    /**
     *  添加订单状态枚举:
     *  灵活处理 数值码表示的状态
     */
    @JsonIgnore
    public OrderStatusEnum getOrderStatusEnum() {
        return EnumUtil.getByCode(orderStatus,OrderStatusEnum.class);
    }

    /**
     *  添加支付状态枚举:
     *  灵活处理 数值码表示的状态
     */
    @JsonIgnore
    public PayStatusEnum getPayStatusEnum() {
        return  EnumUtil.getByCode(payStatus,PayStatusEnum.class);
    }
}
